<?php

/**
 * Atelier filter form base class.
 *
 * @package    tfe
 * @subpackage filter
 * @author     3emeIG
 * @version    SVN: $Id: sfDoctrineFormFilterGeneratedTemplate.php 24171 2009-11-19 16:37:50Z Kris.Wallsmith $
 */
abstract class BaseAtelierFormFilter extends BaseFormFilterDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'libelle'                              => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'animateur'                            => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Animateur'), 'add_empty' => true)),
      'type_artistique'                      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TypeArtistique'), 'add_empty' => true)),
      'type_de_public'                       => new sfWidgetFormChoice(array('choices' => array('' => '', 'enfants' => 'enfants', 'adultes' => 'adultes', 'ados' => 'ados', 'ados-adultes' => 'ados-adultes', 'tous publics' => 'tous publics'))),
      'nombre_de_personnes_max'              => new sfWidgetFormFilterInput(),
      'nombre_de_personnes_min'              => new sfWidgetFormFilterInput(),
      'lieu'                                 => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'add_empty' => true)),
      'ouvert'                               => new sfWidgetFormChoice(array('choices' => array('' => 'yes or no', 1 => 'yes', 0 => 'no'))),
      'prix_avant_saison'                    => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'prix_pendant_saison'                  => new sfWidgetFormFilterInput(),
      'prix_au_semestre'                     => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'prix_pour_membres'                    => new sfWidgetFormFilterInput(),
      'prix_essai'                           => new sfWidgetFormFilterInput(),
      'age_minimum'                          => new sfWidgetFormFilterInput(),
      'age_maximum'                          => new sfWidgetFormFilterInput(),
      'jour'                                 => new sfWidgetFormChoice(array('choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut'                       => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'heure_de_fin'                         => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'jour2'                                => new sfWidgetFormChoice(array('choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut2'                      => new sfWidgetFormFilterInput(),
      'heure_de_fin2'                        => new sfWidgetFormFilterInput(),
      'jour3'                                => new sfWidgetFormChoice(array('choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut3'                      => new sfWidgetFormFilterInput(),
      'heure_de_fin3'                        => new sfWidgetFormFilterInput(),
      'commentaire'                          => new sfWidgetFormFilterInput(),
      'deleted_at'                           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'created_at'                           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'updated_at'                           => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate(), 'with_empty' => false)),
      'courriers_electroniques_envoyes_list' => new sfWidgetFormDoctrineChoice(array('multiple' => true, 'model' => 'CourrierElectronique')),
    ));

    $this->setValidators(array(
      'libelle'                              => new sfValidatorPass(array('required' => false)),
      'animateur'                            => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Animateur'), 'column' => 'id')),
      'type_artistique'                      => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('TypeArtistique'), 'column' => 'id')),
      'type_de_public'                       => new sfValidatorChoice(array('required' => false, 'choices' => array('enfants' => 'enfants', 'adultes' => 'adultes', 'ados' => 'ados', 'ados-adultes' => 'ados-adultes', 'tous publics' => 'tous publics'))),
      'nombre_de_personnes_max'              => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'nombre_de_personnes_min'              => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'lieu'                                 => new sfValidatorDoctrineChoice(array('required' => false, 'model' => $this->getRelatedModelName('Lieu'), 'column' => 'id')),
      'ouvert'                               => new sfValidatorChoice(array('required' => false, 'choices' => array('', 1, 0))),
      'prix_avant_saison'                    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'prix_pendant_saison'                  => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'prix_au_semestre'                     => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'prix_pour_membres'                    => new sfValidatorSchemaFilter('text', new sfValidatorNumber(array('required' => false))),
      'prix_essai'                           => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'age_minimum'                          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'age_maximum'                          => new sfValidatorSchemaFilter('text', new sfValidatorInteger(array('required' => false))),
      'jour'                                 => new sfValidatorChoice(array('required' => false, 'choices' => array('lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut'                       => new sfValidatorPass(array('required' => false)),
      'heure_de_fin'                         => new sfValidatorPass(array('required' => false)),
      'jour2'                                => new sfValidatorChoice(array('required' => false, 'choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut2'                      => new sfValidatorPass(array('required' => false)),
      'heure_de_fin2'                        => new sfValidatorPass(array('required' => false)),
      'jour3'                                => new sfValidatorChoice(array('required' => false, 'choices' => array('' => '', 'lundi' => 'lundi', 'mardi' => 'mardi', 'mercredi' => 'mercredi', 'jeudi' => 'jeudi', 'vendredi' => 'vendredi', 'samedi' => 'samedi', 'dimanche' => 'dimanche'))),
      'heure_de_debut3'                      => new sfValidatorPass(array('required' => false)),
      'heure_de_fin3'                        => new sfValidatorPass(array('required' => false)),
      'commentaire'                          => new sfValidatorPass(array('required' => false)),
      'deleted_at'                           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'created_at'                           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'updated_at'                           => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 00:00:00')), 'to_date' => new sfValidatorDateTime(array('required' => false, 'datetime_output' => 'Y-m-d 23:59:59')))),
      'courriers_electroniques_envoyes_list' => new sfValidatorDoctrineChoice(array('multiple' => true, 'model' => 'CourrierElectronique', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('atelier_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function addCourriersElectroniquesEnvoyesListColumnQuery(Doctrine_Query $query, $field, $values)
  {
    if (!is_array($values))
    {
      $values = array($values);
    }

    if (!count($values))
    {
      return;
    }

    $query->leftJoin('r.AtelierDestinataire AtelierDestinataire')
          ->andWhereIn('AtelierDestinataire.id_courrier_electronique', $values);
  }

  public function getModelName()
  {
    return 'Atelier';
  }

  public function getFields()
  {
    return array(
      'id'                                   => 'Number',
      'libelle'                              => 'Text',
      'animateur'                            => 'ForeignKey',
      'type_artistique'                      => 'ForeignKey',
      'type_de_public'                       => 'Enum',
      'nombre_de_personnes_max'              => 'Number',
      'nombre_de_personnes_min'              => 'Number',
      'lieu'                                 => 'ForeignKey',
      'ouvert'                               => 'Boolean',
      'prix_avant_saison'                    => 'Number',
      'prix_pendant_saison'                  => 'Number',
      'prix_au_semestre'                     => 'Number',
      'prix_pour_membres'                    => 'Number',
      'prix_essai'                           => 'Number',
      'age_minimum'                          => 'Number',
      'age_maximum'                          => 'Number',
      'jour'                                 => 'Enum',
      'heure_de_debut'                       => 'Text',
      'heure_de_fin'                         => 'Text',
      'jour2'                                => 'Enum',
      'heure_de_debut2'                      => 'Text',
      'heure_de_fin2'                        => 'Text',
      'jour3'                                => 'Enum',
      'heure_de_debut3'                      => 'Text',
      'heure_de_fin3'                        => 'Text',
      'commentaire'                          => 'Text',
      'deleted_at'                           => 'Date',
      'created_at'                           => 'Date',
      'updated_at'                           => 'Date',
      'courriers_electroniques_envoyes_list' => 'ManyKey',
    );
  }
}
